package yur.wedding.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;


import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import yur.wedding.modules.sys.entity.SysProcessNodebaseEntity;
import yur.wedding.modules.sys.service.SysProcessNodebaseService;

import yur.wedding.utils.PageUtils;
import yur.wedding.utils.R;
import yur.wedding.validator.ValidatorUtils;


/**
 *   流程节点管理
 *
 * @author Yur
 * @email ${email}
 * @date 2022-05-02 22:54:49
 */
@RestController
@RequestMapping("sys/sysprocessnodebase")
public class SysProcessNodebaseController {
    @Autowired
    private SysProcessNodebaseService sysProcessNodebaseService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:sysprocessnodebase:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysProcessNodebaseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:sysprocessnodebase:info")
    public R info(@PathVariable("id") Integer id){
        SysProcessNodebaseEntity sysProcessNodebase = sysProcessNodebaseService.getById(id);

        return R.ok().put("sysProcessNodebase", sysProcessNodebase);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:sysprocessnodebase:save")
    public R save(@RequestBody SysProcessNodebaseEntity sysProcessNodebase){
        sysProcessNodebaseService.save(sysProcessNodebase);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:sysprocessnodebase:update")
    public R update(@RequestBody SysProcessNodebaseEntity sysProcessNodebase){
        ValidatorUtils.validateEntity(sysProcessNodebase);
        sysProcessNodebaseService.updateById(sysProcessNodebase);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:sysprocessnodebase:delete")
    public R delete(@RequestBody Integer[] ids){
        sysProcessNodebaseService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
